package top.dark.design.patterns.factory.factorymethod;

import java.util.Scanner;

/**
 * Author: Darkn
 * description:
 * Create Time: 2021/4/24 21:25
 */
public abstract class OrderPizza {
    public void orderPizza(){
        do {
            String orderType = getOrderType();
            Pizza pizza = createPizza(orderType);
            if (pizza != null) {
                pizza.prepare();
                pizza.bake();
                pizza.cut();
                pizza.box();
            } else {
                System.out.println("您好，您点的披萨不存在~");
                break;
            }
        } while (true);
    }

    public abstract Pizza createPizza(String orderType);

    public String getOrderType(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入您需要订购的披萨编号：");
        String orderType = scanner.nextLine();
        return orderType;
    }

}
